hmoog / crypto-ts Goto Github PK
View Code? Open in Web Editor NEWTypescript library of crypto standards. Ready for AOT and treeshaking in combination with Angular and other modern typescript frameworks.
License: MIT License
Typescript library of crypto standards. Ready for AOT and treeshaking in combination with Angular and other modern typescript frameworks.
License: MIT License
Most of the modules missing from the package even though they have been listed in the Readme.
(It's only got copied from crypto-js I guess...)
I would need the crypto-ts/hmac-sha384... :)
Also I would gladly help to finish the package.
I have tried the steps described for AES generation for SHA1 / SHA256 without success. I think, this is either a bug or the usage for all cryptos are inconsistent. Please enlighten me.
I am struggling to use Base64 in crypto-ts. I want to return a base64 string of the encryption output. I believe I should use enc.Base64.stringify but I cannot work out how to get it imported using typescript. It looks like it should be added to the following code in src/crypto-ts.ds
Utf8: typeof Utf8;
Hex: typeof Hex;
};```
Is it possible to use Base64 in the current version 1.0.2? Or can we get a new version that makes it available?
Hi.
I wrote a code:
import { AES, enc } from 'crypto-ts'
const essence: Readonly<Array<string>> = ['cccc', 'bbb']
export function encrypt(plain: string): string {
let result = plain
let i = 0
for (const key of essence) {
console.log(`${i++}th: ${result}`)
result = AES.encrypt(result, key).toString()
}
console.log(`${i++}th: ${result}`)
return result
}
export function decrypt(encrypted: string): string {
const reversed = essence.slice().reverse()
let result = encrypted
let i = 0
for (const key of reversed) {
console.log(`${i++}th: ${result}`)
result = AES.decrypt(result, key).toString(enc.Utf8)
}
console.log(`${i++}th: ${result}`)
return result
}
and wrote 2 tests
decrypt ∘ encrypt = id
?
import { equal } from 'assert'
import { encrypt, decrypt } from './password'
equal(
decrypt(encrypt('aaa')),
'aaa',
)
This is succeed. But...
encrypt ∘ decrypt = id
?
import { equal } from 'assert'
import { encrypt, decrypt } from './password'
const encrypted = encrypt('aaa')
equal(
encrypt(decrypt(encrypted)),
encrypted,
)
This is not succeed.
This outputs:
at Object.encrypt (src/data/password.ts:21:13)
0th: aaa
1th: U2FsdGVkX1+dqc1ONOoJe0Emtg7hk3gaw2dFDDpz7i0=
2th: U2FsdGVkX1+T4l2tnqC6DkJhJ267S44fePf2aurDJQ1dnRL2N8gdOgR+e89nafrs2CJABiPL2r8kSL0HfWks3A==
at Object.decrypt (src/data/password.ts:50:13)
0th: U2FsdGVkX1+T4l2tnqC6DkJhJ267S44fePf2aurDJQ1dnRL2N8gdOgR+e89nafrs2CJABiPL2r8kSL0HfWks3A==
1th: U2FsdGVkX1+dqc1ONOoJe0Emtg7hk3gaw2dFDDpz7i0=
2th: aaa
at Object.encrypt (src/data/password.ts:21:13)
0th: aaa
1th: U2FsdGVkX19f6NW8lX7mibHUo2ehVBb+iOC2G1rDFO0=
2th: U2FsdGVkX19rZGGnvKyakv0FHJGx9FgyXivUHkD1xVuPNG8yyiYi8jh3JF372n6diJ/xekV2L7BA2NN4zgn0qA==
This is so strange, because encrypt()
returns different value for the same input.
Some ideas? please x(
I need to encrypty/decrypt tripleDES messages but I couldn't find anything except this listing on README:
Can you tell me if it's implemented?
Cannot use MD5。
Property 'sha1' does not exist on type 'typeof import("....../node_modules/crypto-ts/crypto-ts")'.ts(2339)
var encryptedMessage = AES.encrypt('abcdefg', 'key 12345').toString();
var decryptedMessage = AES.decrypt(encryptedMessage, 'key 12345').toString();
The values I am getting are totally different from each other.
Following are the values I am getting:
encryptedMessage = U2FsdGVkX183SQr+sLeoy/un696pAkxi8F6W69cuezw=
decryptedMessage = 61626364656667
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.