File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- const base64UrlRegex = / - | _ /
21const encryptionAlgorithm = "AES-GCM"
32const ivBytesLength = 12
43
@@ -111,9 +110,31 @@ export async function decryptTextSymmetrically(
111110 textDecoder = new TextDecoder ( )
112111) {
113112
113+ /**
114+ * @type {(boolean|undefined) }
115+ */
116+ let urlSafe
117+
118+ let i = 0
119+
120+ do {
121+ switch ( ciphertext [ i ] ) {
122+ case "-" :
123+ case "_" :
124+ urlSafe = true
125+ break
126+ case "+" :
127+ case "/" :
128+ urlSafe = false
129+ break
130+ default :
131+ i ++
132+ }
133+ } while ( urlSafe === undefined && i < ciphertext . length )
134+
114135 const data = Uint8Array . fromBase64 (
115136 ciphertext ,
116- base64UrlRegex . test ( ciphertext ) ? base64UrlOptions : undefined
137+ urlSafe ? base64UrlOptions : undefined
117138 )
118139
119140 return (
Original file line number Diff line number Diff line change 11{
22 "name" : " singlecrypt-text" ,
3- "version" : " 4.0.2 " ,
3+ "version" : " 4.0.3 " ,
44 "author" : " Stefan Samson <ss42701@outlook.com> (https://ssbit01.github.io/)" ,
55 "repository" : " github:SSbit01/singlecrypt-text" ,
66 "main" : " index.js" ,
You can’t perform that action at this time.
0 commit comments