Skip to content

encryptData & decryptData Encryption & Decryption Tool

Tip

The encryption method is a simple encryption using base64. This method can be directly cracked and should not be used for important data that requires encryption. It is recommended to use md5 encryption for important data.

Function List

encryptData(data) => string

Encrypts an object or string using base64.

Parameters

Parameter NameTypeRequiredDefault ValueDescription
dataobject | stringYes-The object or string to be encrypted

Return Value

TypeDescription
stringThe string after base64 encryption

Example

typescript
import { encryptData } from '@hy-app/ui';

const encryptObj = encryptData({ name: 'Encrypted Object' });
const encryptStr = encryptData('Encrypted String');

decryptData(encryptedVal) => any

Decrypts base64 encrypted data, restoring it to the original data.

Parameters

Parameter NameTypeRequiredDefault ValueDescription
encryptedValstringYes-The encrypted data to be decrypted

Return Value

TypeDescription
anyThe original data after decryption

Example

typescript
import { decryptData } from '@hy-app/ui';

const decryptVal = decryptData('DSSFFGfh234nr');