-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 2793ed9
Showing
35 changed files
with
3,024 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
/node_modules | ||
/.pnp | ||
.pnp.js | ||
|
||
# testing | ||
/coverage | ||
|
||
# production | ||
/build | ||
|
||
# misc | ||
.DS_Store | ||
.env.local | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
|
||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* eslint linebreak-style: ["error", "windows"] */ | ||
|
||
const CONSTANTS = { | ||
HashAlgorithms: { | ||
md2: "MD2", | ||
md5: "MD5", | ||
sha1: "SHA-1", | ||
sha224: "SHA-224", | ||
sha256: "SHA-256", | ||
sha384: "SHA-384", | ||
sha512: "SHA-512", | ||
keccak: "keccak", | ||
}, | ||
|
||
HmacAlgorithms: { | ||
HmacMD5: "HmacMD5", | ||
HmacSHA1: "HmacSHA1", | ||
HmacSHA224: "HmacSHA224", | ||
HmacSHA256: "HmacSHA256", | ||
HmacSHA384: "HmacSHA384", | ||
HmacSHA512: "HmacSHA512", | ||
HmacKeccak: "HmacKeccak", | ||
PBEwithHmacSHA: "PBEwithHmacSHA", | ||
PBEwithHmacSHA1: "PBEwithHmacSHA1", | ||
PBEwithHmacSHA224: "PBEwithHmacSHA224", | ||
PBEwithHmacSHA256: "PBEwithHmacSHA256", | ||
PBEwithHmacSHA384: "PBEwithHmacSHA384", | ||
PBEwithHmacSHA512: "PBEwithHmacSHA512", | ||
}, | ||
}; | ||
|
||
export default CONSTANTS; |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,180 @@ | ||
/* eslint linebreak-style: ["error", "windows"] */ | ||
|
||
|
||
export const TestStrings = [ | ||
'us9zV8OHDVBaQH479jDT', | ||
'jaTFoWMDx3r8Yqm7Cxgw', | ||
'Z6ISc5vJn8NESCNXwQKz', | ||
'0N7lEchwrmUslIrp9stf', | ||
'3FAupVzuqhvtt8B4LxgY', | ||
'gEAlA5TR5HgUNUjqUEoy', | ||
'IW2ADOX0cABxxivr5xA2', | ||
'H66Q4BqAtyusLZjdupxo', | ||
'dKFZwcQoD1b6KBcdOO8T', | ||
'XC2catZcb2eqkqkMu1HP', | ||
]; | ||
|
||
export const Md5Hashes = [ | ||
'1fc961987882c62662dbc39f852ec865', | ||
'a29d1b726173cbfee272607e74d64f6e', | ||
'd95a4dba042c2b032de34cea9f9d0900', | ||
'3773cf456db9cda6e1e1ab77e2d193d6', | ||
'ac94429b44720634e406d80812078be8', | ||
'ec32be7d1945c866171eb2ef5dae5f50', | ||
'b0c9f35d23fe3bbe77a78cd432d128be', | ||
'4c17ba4937a43033559f997885ed08f6', | ||
'a3c5392d8d8b601b3eac2fd27d8180ec', | ||
'bc2b9e80661f92bd92f7d1c38fda45b4', | ||
]; | ||
|
||
export const SHA1Hashes = [ | ||
'3b13aaa4b9db23c447f5980ddb21edc728a2a1c7', | ||
'12a0c65edc236e265c7e0cd640b0a8f2122622b6', | ||
'646cdd03818d7e6d63303afd167855e77eb46dfb', | ||
'29885dc1c07004ffe472bd16558ea5a7f66c2e9a', | ||
'd2bf7d3fe8dbe615c3ae4bebbb84e623e56cda46', | ||
'05e97a715d184e4294786c5a9ea24eba8bca69bb', | ||
'a913fc6db629fe83a969f1a53d47297e359cc4f2', | ||
'ef0c22271507961c786f7304440f595154632c0f', | ||
'3572838373bbed023640350bd3fdd1e427384f63', | ||
'c66a6e8416b0c8913cbd0684e76974b66c8db115', | ||
]; | ||
|
||
export const SHA224Hashes = [ | ||
'54a2e24de0cb2c6b72344b4b98b2a66f149b8c718ff4fb4b9f500776', | ||
'57f120c3587d539d6c6fc8d39e9cf20e47d2fdcb57e749f0563dc15d', | ||
'538f439a4f02a0406b1d5fb079f67e52fb4128cde5833f7c938f6ef8', | ||
'9e426a8ad3271dfc974c0a6f9abbb05d04d7da241f1150ff3837c5ec', | ||
'fc00a251bcb65ebb1ac40af9b82b8301f94bc99fbe608c99e127bb47', | ||
'c10e56075b13543c5e87068bc2992c42866a44e55b2476f0c5f741d6', | ||
'49b9a83d0beb6bb687c8aeef3cceae8436058c9500ca464272eb7f07', | ||
'00f30ea8a2847e74a850579f3b2992718d23059c4d97dca3ea479602', | ||
'f854eb0aa0e65c511fb336a1256daecb42b9532120bbfc7f5aa6e768', | ||
'de694feb9bb07b408ac53eca0f3227e7c781ff389e645e9e6189081f', | ||
]; | ||
|
||
export const SHA256Hashes = [ | ||
'c5b228819cadb84f6942b2d6ba92f9c81216f9b134cb7ede7f5a80ab3a12d7c5', | ||
'2bc90ac81c7b2dcdf2e7ef0b7b8380992f90592fe6d695cd8f766f3fe6685475', | ||
'e68eb79005e1e83645f810d4c6a0629cc9ea646dec53c21f462d6c58c0633eb2', | ||
'9fac7ead4d44cb57753489e6c0d157a13a7d7e4f7536652a60fd17f10705069b', | ||
'0389fe1d90e4fed4fcb9577c570d577c6dcce4d52489ed861c758741a360111c', | ||
'7c48bd857ce34a1262f5f284a54e8aa95b4594dba154a024816fe7e3c53c4bea', | ||
'2e48347dd39c6da6388e4b33e93f0fa7cc5262259f39164ba7acc6c8a7087713', | ||
'7da03e7886751b95ab116572fcf1a2f112b8f9fe7f0b03bc2c3c2dd329901b7a', | ||
'00d3268888070c76a41f9141fa497a4de00e05a342170b02181f35350d91a088', | ||
'192f1bc833b4fad02e6762ea053c35c7256f0356254883db3ab05be1e6c8642b', | ||
]; | ||
|
||
export const SHA384Hashes = [ | ||
'5ea03fd45506de1ac5bd25579db9ddfe5b6ccc209c25b476f91ec0d1b559cda69207adac1a9bbbcd65016301c2343972', | ||
'135fa6735a17a9ffb19d34c857355356cfbc88d2196489444f43511d8ec4e9946b60dcf03220a7a27f36178a78c7ea07', | ||
'715d531c518cf721bf6621e8b138cd2cfe34ea0a5759c83835b8c11cb2314d7a8fe0cd0118af70583ed44a3fe0bbd42d', | ||
'8558463cafabc5574ee51b7310cb4194dc703faf5013c745248cdc1e5f72eee16687e4ff84ca6163daa6f0d4ef02230a', | ||
'2f01fb24253866a728d0160bcd26b660f1ffb75e947ca35f6a139fd9e2a20f97116bfd14568e15d3a4f8e8fc4d7c0ea0', | ||
'37fc82b16b72c8c4670e7360acd50eef98f408a5e5132c7b07f76d22911e8cb80fae60b3708b36d718c8f67dab082ac8', | ||
'9dabbf86b0cb4ab072bd5e0d321198e230bdb57a8da96ec3f396b540ccd8ca0030a12159ff226a331fbd64867a2d059a', | ||
'353fce23f4fe0cae657bcc7f9a263a9505298c07bebe3a74113d8a907e5c448618eb9b35c8d027f462df6d9e47631040', | ||
'd46e8898f3697d143796d1394545faac281761c9b985baf43a7048d29e558c9690934dcdeaf8afa54bf0e1b470ce5a48', | ||
'4f4e4b7bab9223951de8b33fdebed6e8586e2f37f8d2ab9ee150a4e503fd747043c8bcc1b2d68bb8fd3a37a8c7a25e16', | ||
]; | ||
|
||
export const SHA512Hashes = [ | ||
'74079d0ffcf78a71a028cf7fbf24ddf41917c970e1668cc996d7bc2e15df37477e9d2e92c23b675c251e037cac4fa85e9fb167472caba87bb171b4d0b41b286f', | ||
'79ea731298bb5c14183227a6c365b18f9537d0ab810dd2cb16a51987731a6c68e0278b12ccb46b846dda4ec6c432c526afd7d413913a393ff584fbada113d3dd', | ||
'2e5365915acae419f1e67acee8ae09b09305bc51454cbd06db9f51aa060c7b4025ea12581888e0a2967881be97451525b7812cb9dfa5a1121808bd5310fd1887', | ||
'ea1a6e115bbf7f3fde117b5171d66b7a2eb6314d278c8e074bfc7d43d01e1127e80c35686943212db4aca7bba5b2c3cc07065d50e2278b0697bf03098157aa81', | ||
'94aa5a01c3037d2002c93a64b41fd18bc9e839133b8055c791864efc62c4e6fe88083daab3c9d659b823a4779504605c1c7276abe15204b8318da63600a4f064', | ||
'288aae524903c99606a58a12850c02b12005963502a99a7d0897141fb29c5cf6a2f54b0c670607576d6132cb524dd669d59a995c2c3dfd262c2ae3e60a7cb8b2', | ||
'0221d2a5174fd996f00e665ecad987d96a2463a349b953df03a6f5842625d4c36c644fe3598ed95269f8cc1af5e4e2e3cc460798991238730ac32c23f2f3e514', | ||
'b612727f5525b94b35e6d2abeb049a0755934d4aeb778c667f4877037a3a1be003ec91b1f772332294a327901f6f6e7fa8f117ea4ecabff0b1e9ef0a01dc341f', | ||
'c58e3e847dfbb287f25cff06047c68d28b7af17761532d21bc3504d21617a8637b398d27fbeb4d05165763cdee17995da4c811f8f0b21d9e5f54a6760a43f3c3', | ||
'6663cbd90863b625a34c018653304ba5f38b3e2c8ee12b5cf4c0888c59315f45d3da64de7ee2205ebb5909868b877f41cd6172af5ece1ee8fce8266892e3f85c', | ||
]; | ||
|
||
export const KeccakHashes = [ | ||
'605ad18dd4099184b639b639bb3e2f679815346786368eb3b8df4a4334de58e0239fb05cf4c271c1b629cc18886a02b09fc73ae52c839afbabf33fe65a4aa519', | ||
'46ae030006973a2364e96b1fba36781191ff856c1df59fa46c342b8c3695570b47be85f5393d9322dea9f09d7bc00e251a3e05212f8ed73cab026f955cdb9304', | ||
'082c4af82c8c6a0599f1ddea660fc4df995667ddf064a61cb2e575b0c0006aa428bf947502125878e200b35a2bdc8ee46dc7bed74123992d8a0e10b6ca879307', | ||
'24dcce6f3d3409b2a018dfa1882c9110b3f9746167ac86fcf67e265c78f9a543dba4cd9b16b14cbd62138ef9caf87a601053b3a77b19afcab9d43124a20b5648', | ||
'b261a5a6e0ce78f05c7ef58d4e0d4b559f2a6653595f3428c773104c9604b5aea96cf68143ae3798eaa937090378fdb826aa35f79fb16f704e62620ece6306ca', | ||
'bb69d00c06cfc857deb176a243244fc7753969c707999850887c1bd8f34fe0df63e6b642cb60d4b8dac6c33bd5c44ed0c509b885a2cd796b07a3378a3f8d1284', | ||
'05a269306e21f8112bd0427d5267006c26c3dfa62876660cdd166e6207ac34faebce49de589bbcf62b530197a28ab6e247b2662b2641bee2a819ea5678bfec9a', | ||
'78c8d2f2daf0b81390bce7b32e59f1fdaae86803845d92aeb0de29c08e9e35422d3a1e23d98e2255d099d1d487d2e9cdf62271cbffa12a2714c19da728531b80', | ||
'3eb3697b783bca8bec67465dee6e61cfdd57f607a0ec74c485b9910fb63574696790627433ef68f6004a7b5a194ffc43ef18549632b6c0c4d044e0a2e864a341', | ||
'b4bd752b678bd4984b525ac96ed926fbaa2a9d947511e2eedbff6014d6bfd252ef869f39d12e134eeea4d1f3d081e16ed0623b5b55c2fac82f4aa78a81cd3058', | ||
]; | ||
|
||
export const HmacMD5s = [ | ||
'748889632936ea35596b7b168b091c46', | ||
'ea46c9997bbb207d708ebd3803a95c95', | ||
'a5b781d647c9c543bde19a8f72e66f78', | ||
'696f256ea4f4abb58cc6de0fdf394987', | ||
'e777e13c8b1b83fd09be00a34859ff0a', | ||
'a84c8d8e5a28bbe5fa2ed082dcc63699', | ||
'c777f86f8769af6879e63fb1e49dcc85', | ||
'6138a50c103ca5530095addb3f98b4af', | ||
'9c838331be63395c09137c19dd791c8b', | ||
'356a60aebbee31e3720c3837ce285ac6', | ||
]; | ||
|
||
export const HmacSHA1s = [ | ||
'a10243addc246736db4789abcf43851678635d88', | ||
'83f6f2aa70502e442b68c81e8507a30520318505', | ||
'9b94353b9ce379a5b2fb00151ba234c4cf5b7b13', | ||
'52bd32b028de2a845e405a0ba54243e9c9dd23a1', | ||
'a83b61487daf89c7f1e22ca4111c2ea17b56e042', | ||
'b403275b16fac1286c358d27dc86e12ebca7cbbd', | ||
'2eb392eadc64a638c0e9f9ebb519025de0b56e64', | ||
'2d793bbbbfaaa7455e4db91921a96f285e25a246', | ||
'709654d5292a2a1dededf18ed82c26297031d704', | ||
'3d393a448b2847c1f4bd14c2ce962ac7883bc974', | ||
]; | ||
export const HmacSHA224s = [ | ||
'53c806b54a6f27b31e7e7f0d5860837ef08992d4854c4f632113b8f8', | ||
'23d975ecbe4c45f9ecc7826f94494fb5b95d10d2e58ef422dd8a2fe7', | ||
'f0bcb13f422bedde9ac5b446cec301c34f35e2bab2791bb305c1ddd3', | ||
'b0deba2528b94be953e116b4680ed8087c5df86f6e2629530b3e04b5', | ||
'814f38ad8d14b4fa0b4c501f14daeaf52fc4cbf83618aa0d31bcef3f', | ||
'2af010cd545e6786c5f9f4af2f05883a6015c8f496cfeb08aaad35d3', | ||
'cbd7908fd7d4c3d263643d28817a9bf23eab56be774e07806c65d145', | ||
'8e65e43d3dea30fa881a94c6e6fbc815d9568aa74bc42f2de7e8d1ea', | ||
'bbc59772df7810dda39889dbf92db7cc38dae8881ff93a1dd44b0f79', | ||
'6925b5b3cb55eb33229b47b88f625bd99a9c881dda9425cec2a44025', | ||
]; | ||
export const HmacSHA256s = [ | ||
'4897d258ad80d91b937a512185a00286b6a7cdbb24d5f117266d25915d8352e7', | ||
'2104295906bb6b69722cd6350ebb7de47840da946830c9fdc8bf417be6efdefd', | ||
'374f1b9067bef2a7603528761ab6b122247edda8536b63212b337e8b0ec0ff09', | ||
'81fda63d8c2f61d77383ba3e97751b676036f8c5f1ce50a212e704727b445a5e', | ||
'e29165e344b66b8ec695f4a9bb53490f75e69fe77ec874bcf74ea1979a3190cb', | ||
'21d32a60335d6bf60ae03200c5317c553600420effcfaef68c4ddc6fb0b4196c', | ||
'b8496df72cd941d63b015886513415daf37e4096fca1cea504079b97daed04b4', | ||
'740e41ee32532bdf95d1b3f55a17c0bd1dcf66ef887af993e78e199bf528d897', | ||
'011ec9ee63218632143fd3a699eb1b6c4dce939a709e5adaa248e2af52591f1b', | ||
'f8e19bd799a0de44e755bb042e8c563eddeddcdfb97283e9738e426dd31e6d8f', | ||
]; | ||
export const HmacSHA384s = [ | ||
'93348d6f3560dffd06447a2bf880fe22e7d32cf79a880611035a98bb3bbf435a3cc42222e8019c89395a87c6018d9a68', | ||
'fd2e7bb5ba0f7083f1efba8efadf5770f0d958d24ce41771e453f3c7c21727c01b3f5049c72e7511f5efe0803f985323', | ||
'c26ea7c941de3f619467cd612e3a0cf4ce067c2b44add8cf12605b41e0c403f72bd56d2cc37997ed2d8287441fd9d501', | ||
'59e2b148078132be1a66299a0142abfafbb6b1b3c74fe7ac74e40e6c9e6cae7ba6275db233505fed799924405a273418', | ||
'0f6d31cc989f894a56a57b59fe5e045f62c01d63066b22f48704f5299af3a69fde8d7d24040565222ba6082ca2fe114b', | ||
'484b867672907031eca07281eda343df2ed7223b540adb27e96d1611c722d562cd69f13382e73e0277e278ae6e636b25', | ||
'afbb8b1789b5ff0bae94c47564ba3c4b1058334c1ceca3f4b5082b0ddc00496e6f72cd07106d5e05da68e8a6f8c99905', | ||
'2296c764ae33f6c66b799b1a9038c3de230ce72e9a11f2eba3d81e29dc31a0c59e765a4985e4479a951f4dd88dbcd280', | ||
'2f01b252b9d8a038bccde5e68d9e3d2703d8893dedc847cade2dff4042ee2a77a1f876631c7e44ba2011a8ad80c5f237', | ||
'cf0ee2ed40091695bb4f1b69daa76527751310c0599bc85f7a423e79aa300c5ec29cb1570d1ba3b8f6c176413009c8f8', | ||
]; | ||
export const HmacSHA512s = [ | ||
'8dee6c55848c26b97b2e6da2ed6bb62122818689e8827427d553858c98a1bab579dbcebadc2d44a28765cfdff3a136cd568ad4ce0593707c386dc358d7f22409', | ||
'fb0d56555bf6c366cfa4f6cf4f0487032cf32396bea5999498a739eb6c3058c833d5f0f2df00b24863060f8bbd710d02923815787fcc537eb791785b1d43618b', | ||
'97c1bb4b43ba62d387165b43e8f792ba38d7f9437528e80dcd6ef2acc3c0559fad85d499d53de5ebc8e107508a39ae0327ca2554b4f46d2b0d9c135838ef9cfa', | ||
'0d0b1ca2bb4883faab8959039c9b94d53834f96718a7bb99faf5c4e7eee0f8000be320094744912df9be5b7dc939dc5eb86c0cf528265239e3dee0df3841a531', | ||
'cd8dd83afa1ba5d0ffd852e3fef0ab28a7bbc458ea24b644e2a41124a4a0d6adc9a06a31f2d23d284c6be5150db842e4c1adccac78bd3133b16df8cf6b81816a', | ||
'1c0c9124604d50498ce9ff598f722dc6b3fd1b799e7635c271e29bbcc11d4d616d7cc5dd5acb82cb4cfb414a7162c0f2c58b9f1ae94abf103114f8fff4b75c8c', | ||
'1ef19031b6b0b998cec8bf939d3d3b2659af878af6b5373e760e2828a975f1458183a6eab2a80da8688b82e46c731e896261ea73fcc79a9789a44b96edf25de5', | ||
'47860823fb6b496f5cb895f429b3c6dd8bd40c1ad32d164d3926a10e0429f69b8b6af2406847b70aec9bddc23d3a6dbc5fc6db6762def0dcfe115eb3ca00d9a9', | ||
'25bb10507d8d7cbd9c392c2b79209471524032d4c9a0a69d6a990f4ecbabdc32efdae462bc0344dfbb6e7f52a4f26f724413a2ac3a72d23b1adb113d779fd164', | ||
'cce44221fe74defc5bf1f14761c7482969ef2e8a282dd0918d276055eb62b1509cdbdac597f461849f047c6624ef260f6436d8cc2c54575cf46d0fdc8a110721', | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { waitFor } from "@testing-library/react"; | ||
import { renderHook } from "@testing-library/react/pure"; | ||
import { act } from "react-test-renderer"; | ||
import useHash from "./../src/Hash/Hooks/useHash"; | ||
import CONSTANTS from "../Constants"; | ||
|
||
test("should use hook", async () => { | ||
const { result } = renderHook(() => useHash()); | ||
|
||
expect(typeof result.current.setAlgo).toBe("function"); | ||
expect(typeof result.current.setMessage).toBe("function"); | ||
await waitFor(() => | ||
expect(result.current.hashed).toBe("39d11ab1c3c6c9eab3f5b3675f438dbf") | ||
); | ||
}); | ||
|
||
test("should use initial message", async () => { | ||
const { result } = renderHook(() => useHash(CONSTANTS.HashAlgorithms.md5, "testMessage")); | ||
await waitFor(() => | ||
expect(result.current.hashed).toBe("c703b927a0c5d56e5a33c4b834053bd4") | ||
); | ||
}); | ||
|
||
test("should update message", async () => { | ||
const { result } = renderHook(() => useHash(CONSTANTS.HashAlgorithms.md5)); | ||
|
||
await waitFor(() => | ||
expect(result.current.hashed).toBe("39d11ab1c3c6c9eab3f5b3675f438dbf") | ||
); | ||
act(() => result.current.setMessage("testMessage1")); | ||
await waitFor(() => | ||
expect(result.current.hashed).toBe("dccf67b5b214dc38e729958f6a6be829") | ||
); | ||
act(() => result.current.setMessage("testMessage2")); | ||
await waitFor(() => | ||
expect(result.current.hashed).toBe("1ddfe493cdf4176866742a4afa04c840") | ||
); | ||
}); | ||
|
||
test("should update algo", async () => { | ||
const { result } = renderHook(() => useHash(CONSTANTS.HashAlgorithms.md5, "testMessage")); | ||
|
||
await waitFor(() => | ||
expect(result.current.hashed).toBe("c703b927a0c5d56e5a33c4b834053bd4") | ||
); | ||
act(() => result.current.setAlgo(CONSTANTS.HashAlgorithms.sha1)); | ||
await waitFor(() => | ||
expect(result.current.hashed).toBe("d2581121a80ea419e91878d321100cc99dfb21db") | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = { | ||
presets: [ | ||
'@babel/preset-env', | ||
['@babel/preset-react', {runtime: 'automatic'}], | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
export namespace CONSTANTS { | ||
export namespace HashAlgorithms { | ||
export const md2: string; | ||
export const md5: string; | ||
export const sha1: string; | ||
export const sha224: string; | ||
export const sha256: string; | ||
export const sha384: string; | ||
export const sha512: string; | ||
export const keccak: string; | ||
} | ||
export namespace HmacAlgorithms { | ||
export const HmacMD5: string; | ||
export const HmacSHA1: string; | ||
export const HmacSHA224: string; | ||
export const HmacSHA256: string; | ||
export const HmacSHA384: string; | ||
export const HmacSHA512: string; | ||
export const PBEwithHmacSHA: string; | ||
export const PBEwithHmacSHA1: string; | ||
export const PBEwithHmacSHA224: string; | ||
export const PBEwithHmacSHA256: string; | ||
export const PBEwithHmacSHA384: string; | ||
export const PBEwithHmacSHA512: string; | ||
} | ||
export namespace Events { | ||
export const onBatchReccieved: string; | ||
} | ||
} | ||
|
||
export function JSHash(message: string, algorithm: string): Promise<string>; | ||
|
||
export function JSHmac(message: string, secret: string, algorithm: string): Promise<string>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|
||
/* eslint linebreak-style: ["error", "windows"] */ | ||
/* eslint-disable no-use-before-define */ | ||
|
||
export { default as JSHash } from './src/Hash/JSHash'; | ||
export { default as useHash } from './src/Hash/Hooks/useHash' | ||
export { default as JSHmac } from './src/Hash/JSHmac'; | ||
export { default as CONSTANTS } from './Constants'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
"name": "react-hash", | ||
"version": "0.1.0", | ||
"private": true, | ||
"dependencies": { | ||
"crypto-js": "^4.1.1", | ||
"react": "^18.2.0" | ||
}, | ||
"scripts": { | ||
"test": "jest" | ||
}, | ||
"jest": { | ||
"testEnvironment": "jsdom", | ||
"testPathIgnorePatterns": [ | ||
"__tests__/C" | ||
] | ||
}, | ||
"eslintConfig": { | ||
"extends": [] | ||
}, | ||
"devDependencies": { | ||
"@babel/preset-env": "^7.18.6", | ||
"@babel/preset-react": "^7.18.6", | ||
"@testing-library/react": "^13.3.0", | ||
"babel-jest": "^28.1.3", | ||
"jest": "^28.1.3", | ||
"jest-environment-jsdom": "^28.1.3", | ||
"react-dom": "^18.2.0", | ||
"react-test-renderer": "^18.2.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import React, { useState, useEffect } from "react"; | ||
import hashString from "../JSHash"; | ||
import CONSTANTS from "../../../Constants"; | ||
const useHash = (hashAlgo = CONSTANTS.HashAlgorithms.md5, initialMessage = "hello World") => { | ||
const [Algo, setAlgo] = useState(hashAlgo); | ||
const [message, setMessage] = useState(initialMessage); | ||
const [hashed, setHashed] = useState(); | ||
useEffect(() => { | ||
const hash = () => | ||
hashString(message, Algo) | ||
.then((a) => setHashed(a)) | ||
.catch((er) => { | ||
console.error(er); | ||
}); | ||
hash(); | ||
}, [message,Algo]); | ||
|
||
return { hashed, setAlgo, setMessage }; | ||
}; | ||
|
||
export default useHash; |
Oops, something went wrong.