mirror of
https://github.com/cupcakearmy/occulto.git
synced 2024-12-21 18:06:27 +00:00
readme
This commit is contained in:
parent
5babec20ce
commit
1ab82a78fe
38
README.md
38
README.md
@ -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)
|
|
||||||
```
|
```
|
||||||
|
Loading…
Reference in New Issue
Block a user