crypto-js vs jsrsasign vs node-jose vs jsencrypt vs jsonwebtoken
웹 개발 암호화 라이브러리
crypto-jsjsrsasignnode-josejsencryptjsonwebtoken유사 패키지:

웹 개발 암호화 라이브러리

웹 개발에서 암호화는 데이터의 기밀성과 무결성을 보장하는 데 필수적입니다. 이 라이브러리들은 다양한 암호화 알고리즘과 기능을 제공하여 개발자가 안전한 애플리케이션을 구축할 수 있도록 돕습니다. 각 라이브러리는 특정 사용 사례와 요구 사항에 맞춰 설계되었으며, 이를 통해 개발자는 자신의 필요에 맞는 최적의 솔루션을 선택할 수 있습니다.

npm 다운로드 트렌드

3 년

GitHub Stars 순위

통계 세부사항

패키지
다운로드
Stars
크기
Issues
발행일
라이선스
crypto-js25,918,43316,399487 kB2793年前MIT
jsrsasign2,328,3743,369890 kB363ヶ月前MIT
node-jose1,945,774720353 kB754年前Apache-2.0
jsencrypt636,9506,806901 kB1461年前MIT
jsonwebtoken018,18243.4 kB2161年前MIT

기능 비교: crypto-js vs jsrsasign vs node-jose vs jsencrypt vs jsonwebtoken

암호화 알고리즘 지원

  • crypto-js:

    Crypto-js는 AES, DES, Triple DES, Rabbit, RC4 등 다양한 대칭 암호화 알고리즘을 지원합니다. 이러한 알고리즘들은 데이터의 기밀성을 보장하는 데 효과적입니다.

  • jsrsasign:

    jsrsasign은 RSA, DSA, ECDSA와 같은 다양한 서명 알고리즘을 지원하며, X.509 인증서 및 PKCS#7 서명 기능도 제공합니다.

  • node-jose:

    Node-jose는 JWE 및 JWS를 지원하며, 다양한 암호화 알고리즘을 사용할 수 있는 유연성을 제공합니다.

  • jsencrypt:

    JSEncrypt는 RSA 알고리즘을 사용하여 비대칭 암호화를 제공합니다. 공개키와 개인키를 사용하여 데이터를 안전하게 암호화할 수 있습니다.

  • jsonwebtoken:

    jsonwebtoken은 JWT를 생성하고 검증하는 기능을 제공하며, HMAC, RSA, ECDSA와 같은 다양한 서명 알고리즘을 지원합니다.

사용 용이성

  • crypto-js:

    Crypto-js는 간단한 API를 제공하여 사용하기 쉽고, 브라우저와 Node.js 환경 모두에서 사용할 수 있습니다.

  • jsrsasign:

    jsrsasign은 다양한 기능을 제공하지만, 그만큼 복잡성이 높아 사용하기 위해서는 다소 학습이 필요합니다.

  • node-jose:

    Node-jose는 고급 기능을 제공하지만, 사용하기 위해서는 JWK 및 JWE에 대한 이해가 필요합니다.

  • jsencrypt:

    JSEncrypt는 직관적인 API를 제공하여 RSA 암호화를 쉽게 구현할 수 있도록 돕습니다. 공개키와 개인키를 쉽게 생성하고 사용할 수 있습니다.

  • jsonwebtoken:

    jsonwebtoken은 JWT 생성 및 검증을 위한 간단한 메서드를 제공하여 빠르게 통합할 수 있습니다.

성능

  • crypto-js:

    Crypto-js는 경량 라이브러리로, 클라이언트 측에서 빠른 암호화 및 복호화 작업을 수행할 수 있습니다.

  • jsrsasign:

    jsrsasign은 다양한 기능을 제공하지만, 복잡한 작업에서는 성능 저하가 발생할 수 있습니다.

  • node-jose:

    Node-jose는 다양한 암호화 및 서명 기능을 제공하지만, 복잡한 암호화 작업에서는 성능이 저하될 수 있습니다.

  • jsencrypt:

    JSEncrypt는 RSA 알고리즘을 사용하므로 대칭 암호화보다 느릴 수 있지만, 보안성이 높은 암호화를 제공합니다.

  • jsonwebtoken:

    jsonwebtoken은 JWT를 사용하여 인증 정보를 안전하게 전송할 수 있으며, 성능이 뛰어난 검증 기능을 제공합니다.

보안성

  • crypto-js:

    Crypto-js는 다양한 암호화 알고리즘을 제공하여 데이터의 기밀성을 보장합니다. 그러나 키 관리에 주의해야 합니다.

  • jsrsasign:

    jsrsasign은 X.509 인증서 및 다양한 서명 알고리즘을 지원하여 높은 보안성을 제공합니다.

  • node-jose:

    Node-jose는 JWE 및 JWS를 통해 데이터의 기밀성과 무결성을 보장하며, 다양한 암호화 알고리즘을 지원합니다.

  • jsencrypt:

    JSEncrypt는 RSA 암호화를 통해 높은 보안성을 제공하지만, 키 길이에 따라 성능이 영향을 받을 수 있습니다.

  • jsonwebtoken:

    jsonwebtoken은 JWT를 사용하여 안전하게 인증 정보를 전송할 수 있으며, 서명 검증을 통해 데이터의 무결성을 보장합니다.

커뮤니티 및 문서화

  • crypto-js:

    Crypto-js는 널리 사용되는 라이브러리로, 풍부한 문서와 커뮤니티 지원이 있습니다.

  • jsrsasign:

    jsrsasign은 다소 복잡한 문서가 있지만, 다양한 기능을 제공하여 많은 개발자들이 사용하고 있습니다.

  • node-jose:

    Node-jose는 고급 기능을 제공하지만, 문서화가 다소 부족할 수 있어 사용에 주의가 필요합니다.

  • jsencrypt:

    JSEncrypt는 사용하기 쉬운 문서와 예제가 제공되어 초보자도 쉽게 접근할 수 있습니다.

  • jsonwebtoken:

    jsonwebtoken은 광범위한 문서와 커뮤니티 지원이 있어 다양한 사용 사례를 쉽게 찾아볼 수 있습니다.

선택 방법: crypto-js vs jsrsasign vs node-jose vs jsencrypt vs jsonwebtoken

  • crypto-js:

    Crypto-js는 다양한 암호화 알고리즘을 지원하며, 클라이언트 측에서 간단한 암호화 및 복호화 작업을 수행할 때 유용합니다. 브라우저에서 직접 사용할 수 있는 경량 라이브러리를 찾고 있다면 이 패키지를 선택하세요.

  • jsrsasign:

    jsrsasign은 다양한 암호화 및 서명 기능을 제공하며, 특히 X.509 인증서와 관련된 작업에 유용합니다. 복잡한 인증서 관리 및 서명 기능이 필요하다면 이 패키지를 선택하세요.

  • node-jose:

    Node-jose는 JSON 객체 서명 및 암호화를 위한 라이브러리로, JWK(JSON Web Key)와 JWE(JSON Web Encryption)를 지원합니다. 복잡한 암호화 요구 사항이 있을 경우 이 패키지를 선택하세요.

  • jsencrypt:

    JSEncrypt는 RSA 암호화에 특화되어 있으며, 공개키와 개인키를 사용한 데이터 암호화가 필요할 때 적합합니다. 클라이언트 측에서 RSA 암호화를 구현해야 하는 경우 이 패키지를 선택하세요.

  • jsonwebtoken:

    jsonwebtoken은 JSON 웹 토큰(JWT)을 생성하고 검증하는 데 사용됩니다. 인증 및 권한 부여 시스템을 구축할 때 JWT를 사용해야 한다면 이 라이브러리를 선택하세요.

crypto-js의 README

crypto-js

JavaScript library of crypto standards.

Discontinued

Active development of CryptoJS has been discontinued. This library is no longer maintained.

Nowadays, NodeJS and modern browsers have a native Crypto module. The latest version of CryptoJS already uses the native Crypto module for random number generation, since Math.random() is not crypto-safe. Further development of CryptoJS would result in it only being a wrapper of native Crypto. Therefore, development and maintenance has been discontinued, it is time to go for the native crypto module.

Node.js (Install)

Requirements:

  • Node.js
  • npm (Node.js package manager)
npm install crypto-js

Usage

ES6 import for typical API call signing use case:

import sha256 from 'crypto-js/sha256';
import hmacSHA512 from 'crypto-js/hmac-sha512';
import Base64 from 'crypto-js/enc-base64';

const message, nonce, path, privateKey; // ...
const hashDigest = sha256(nonce + message);
const hmacDigest = Base64.stringify(hmacSHA512(path + hashDigest, privateKey));

Modular include:

var AES = require("crypto-js/aes");
var SHA256 = require("crypto-js/sha256");
...
console.log(SHA256("Message"));

Including all libraries, for access to extra methods:

var CryptoJS = require("crypto-js");
console.log(CryptoJS.HmacSHA1("Message", "Key"));

Client (browser)

Requirements:

  • Node.js
  • Bower (package manager for frontend)
bower install crypto-js

Usage

Modular include:

require.config({
    packages: [
        {
            name: 'crypto-js',
            location: 'path-to/bower_components/crypto-js',
            main: 'index'
        }
    ]
});

require(["crypto-js/aes", "crypto-js/sha256"], function (AES, SHA256) {
    console.log(SHA256("Message"));
});

Including all libraries, for access to extra methods:

// Above-mentioned will work or use this simple form
require.config({
    paths: {
        'crypto-js': 'path-to/bower_components/crypto-js/crypto-js'
    }
});

require(["crypto-js"], function (CryptoJS) {
    console.log(CryptoJS.HmacSHA1("Message", "Key"));
});

Usage without RequireJS

<script type="text/javascript" src="path-to/bower_components/crypto-js/crypto-js.js"></script>
<script type="text/javascript">
    var encrypted = CryptoJS.AES(...);
    var encrypted = CryptoJS.SHA256(...);
</script>

API

See: https://cryptojs.gitbook.io/docs/

AES Encryption

Plain text encryption

var CryptoJS = require("crypto-js");

// Encrypt
var ciphertext = CryptoJS.AES.encrypt('my message', 'secret key 123').toString();

// Decrypt
var bytes  = CryptoJS.AES.decrypt(ciphertext, 'secret key 123');
var originalText = bytes.toString(CryptoJS.enc.Utf8);

console.log(originalText); // 'my message'

Object encryption

var CryptoJS = require("crypto-js");

var data = [{id: 1}, {id: 2}]

// Encrypt
var ciphertext = CryptoJS.AES.encrypt(JSON.stringify(data), 'secret key 123').toString();

// Decrypt
var bytes  = CryptoJS.AES.decrypt(ciphertext, 'secret key 123');
var decryptedData = JSON.parse(bytes.toString(CryptoJS.enc.Utf8));

console.log(decryptedData); // [{id: 1}, {id: 2}]

List of modules

  • crypto-js/core
  • crypto-js/x64-core
  • crypto-js/lib-typedarrays

  • crypto-js/md5
  • crypto-js/sha1
  • crypto-js/sha256
  • crypto-js/sha224
  • crypto-js/sha512
  • crypto-js/sha384
  • crypto-js/sha3
  • crypto-js/ripemd160

  • crypto-js/hmac-md5
  • crypto-js/hmac-sha1
  • crypto-js/hmac-sha256
  • crypto-js/hmac-sha224
  • crypto-js/hmac-sha512
  • crypto-js/hmac-sha384
  • crypto-js/hmac-sha3
  • crypto-js/hmac-ripemd160

  • crypto-js/pbkdf2

  • crypto-js/aes
  • crypto-js/tripledes
  • crypto-js/rc4
  • crypto-js/rabbit
  • crypto-js/rabbit-legacy
  • crypto-js/evpkdf

  • crypto-js/format-openssl
  • crypto-js/format-hex

  • crypto-js/enc-latin1
  • crypto-js/enc-utf8
  • crypto-js/enc-hex
  • crypto-js/enc-utf16
  • crypto-js/enc-base64

  • crypto-js/mode-cfb
  • crypto-js/mode-ctr
  • crypto-js/mode-ctr-gladman
  • crypto-js/mode-ofb
  • crypto-js/mode-ecb

  • crypto-js/pad-pkcs7
  • crypto-js/pad-ansix923
  • crypto-js/pad-iso10126
  • crypto-js/pad-iso97971
  • crypto-js/pad-zeropadding
  • crypto-js/pad-nopadding

Release notes

4.2.0

Change default hash algorithm and iteration's for PBKDF2 to prevent weak security by using the default configuration.

Custom KDF Hasher

Blowfish support

4.1.1

Fix module order in bundled release.

Include the browser field in the released package.json.

4.1.0

Added url safe variant of base64 encoding. 357

Avoid webpack to add crypto-browser package. 364

4.0.0

This is an update including breaking changes for some environments.

In this version Math.random() has been replaced by the random methods of the native crypto module.

For this reason CryptoJS might not run in some JavaScript environments without native crypto module. Such as IE 10 or before or React Native.

3.3.0

Rollback, 3.3.0 is the same as 3.1.9-1.

The move of using native secure crypto module will be shifted to a new 4.x.x version. As it is a breaking change the impact is too big for a minor release.

3.2.1

The usage of the native crypto module has been fixed. The import and access of the native crypto module has been improved.

3.2.0

In this version Math.random() has been replaced by the random methods of the native crypto module.

For this reason CryptoJS might does not run in some JavaScript environments without native crypto module. Such as IE 10 or before.

If it's absolute required to run CryptoJS in such an environment, stay with 3.1.x version. Encrypting and decrypting stays compatible. But keep in mind 3.1.x versions still use Math.random() which is cryptographically not secure, as it's not random enough.

This version came along with CRITICAL BUG.

DO NOT USE THIS VERSION! Please, go for a newer version!

3.1.x

The 3.1.x are based on the original CryptoJS, wrapped in CommonJS modules.