MCPcopy Create free account
hub / github.com/027xiguapi/code-box / decryptSecretString

Method decryptSecretString

utils/encryption.ts:29–63  ·  view source on GitHub ↗
(secret: string)

Source from the content-addressed store, hash-verified

27 }
28
29 decryptSecretString(secret: string): string | null {
30 try {
31 if (!this.password) {
32 return secret
33 }
34
35 const decryptedSecret = CryptoJS.AES.decrypt(
36 secret,
37 this.password
38 ).toString(CryptoJS.enc.Utf8)
39
40 if (!decryptedSecret) {
41 return null
42 }
43
44 if (decryptedSecret.length < 8) {
45 return null
46 }
47
48 // Validate secret format
49 if (
50 !/^[A-Z2-7]+=*$/i.test(decryptedSecret) && // Base32 format
51 !/^[0-9a-f]+$/i.test(decryptedSecret) && // Hex format
52 !/^blz-/.test(decryptedSecret) && // Blizzard format
53 !/^bliz-/.test(decryptedSecret) && // Alternative Blizzard format
54 !/^stm-/.test(decryptedSecret) // Steam format
55 ) {
56 return null
57 }
58
59 return decryptedSecret
60 } catch (error) {
61 return null
62 }
63 }
64
65 decryptEncSecret(entry: any): any | null {
66 try {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected