2 Commits

Author SHA1 Message Date
1ab82a78fe readme 2023-01-14 18:49:31 +01:00
5babec20ce stable version 2023-01-14 18:42:49 +01:00
2 changed files with 29 additions and 11 deletions

View File

@@ -33,8 +33,10 @@ npm i occulto
```typescript ```typescript
import { RSA } from 'occulto' import { RSA } from 'occulto'
const pair = await RSA.generateKeyPair() const pair = await RSA.generateKeyPair(2 ** 11)
const encrypted = await RSA.encrypt('some text', pair.public) const bytes = Bytes.encode(message)
const encrypted = await RSA.encrypt(bytes, pair.public)
const decrypted = await RSA.decrypt(encrypted, pair.private) const decrypted = await RSA.decrypt(encrypted, pair.private)
``` ```
@@ -42,11 +44,29 @@ const decrypted = await RSA.decrypt(encrypted, pair.private)
[Available Modes](https://occulto.pages.dev/enums/Modes) [Available Modes](https://occulto.pages.dev/enums/Modes)
```javascript There is an _easy_ API, that will take care of everything for you.
import { Symmetric } from 'occulto'
const encrypted = await Symmetric.encryptEasy('some string', 'myPass') ```typescript
const decrypted = await Symmetric.decryptEasy(encrypted, 'myPass') import { AES } from 'occulto'
const password = 'foobar'
const message = 'this is a secret'
const encrypted = await AES.encryptEasy(message, password)
const decrypted = await AES.decryptEasy(encrypted, password)
```
The low level API is also exposed for advanced usages.
```typescript
import { AES } from 'occulto'
const message = 'this is a secret'
const key = await AES.generateKey()
const data = Bytes.encode(message)
const ciphertext = await AES.encrypt(data, key)
const plaintext = await AES.decrypt(ciphertext, key)
``` ```
### [Hash](https://occulto.pages.dev/classes/Hash) ### [Hash](https://occulto.pages.dev/classes/Hash)
@@ -54,9 +74,7 @@ const decrypted = await Symmetric.decryptEasy(encrypted, 'myPass')
[Available hashes](https://occulto.pages.dev/enums/Hashes) [Available hashes](https://occulto.pages.dev/enums/Hashes)
```typescript ```typescript
import { Hash } from 'occulto' import { Hash, Hashes } from 'occulto'
const hash = Hash.digest('something') const hashed = await Hash.hash('Some value', Hashes.SHA_512)
const h = Hash.digest('something', Hash.Hashes.MD5)
``` ```

View File

@@ -1,6 +1,6 @@
{ {
"name": "occulto", "name": "occulto",
"version": "2.0.0-rc.10", "version": "2.0.0",
"license": "MIT", "license": "MIT",
"description": "crypt utility", "description": "crypt utility",
"keywords": [ "keywords": [