open-index/open-npm huggingface dataset:
npm package: @sentinel-one/decrypt-ssh-private
Description: Decrypts ssh keys in the browser
Latest version: 0.0.10

# decrypt-ssh-private

[![npm version](https://d25lcipzij17d.cloudfront.net/badge.svg?id=js&type=6&v=0.1&x2=0)](https://www.npmjs.com/package/@sentinel-one/decrypt-ssh-private)
[![License](https://img.shields.io/badge/License-BSD-green.svg)](https://github.com/Sentinel-One/decrypt-ssh-private/blob/master/LICENSE)
[![Node.js CI](https://github.com/Sentinel-One/decrypt-ssh-private/actions/workflows/node.js.yml/badge.svg)](https://github.com/Sentinel-One/decrypt-ssh-private/actions/workflows/node.js.yml)


A TS library that decrypts ssh keys in the browser.


Based on the nodejs [node-sshpk](https://github.com/joyent/node-sshpk)
and uses [forge](https://github.com/digitalbazaar/forge) where possible.

Credit:

The authors of [node-sshpk](https://github.com/joyent/node-sshpk).

Special thanks to [Ido Kotler](https://github.com/idokot) (Sentinelone Innovative security researcher) for technical guidance and help in implementation  💣.

API:

```ts
import { decryptPrivateSSHKey } from '../lib/main';
import { ErrorClassification, ResultT } from '../lib/error-classifier';

const result: ResultT<ErrorClassification, string> = decryptPrivateSSHKey(encryptedSSHKey, { passphrase: '123456' });
result
  .ok((output: string) => {
    console.log(output);
    return result;
  })
  .err((err: ErrorClassification) => {
    // do something with the classified error
    console.log(err);
    return result;
  });
  ```

### Util functions

* isValidSSHKey(pem: string): boolean // Checks that a given PEM format is valid or not


```typescript
if (isValidSSHKey('invalid key')) {
  // do sothing
};

```


To see it decrypts in the browser just build and serve the example:

`esbuild-browser && npx http-server`


## Contributers 
[Liron Hazan](https://github.com/LironHazan)

[Vova Shabun](https://github.com/vovasdev)