https://github.com/nexckycort/rijndael-nodejs
Implementation of the rijndael encryption algorithm.🛡️
https://github.com/nexckycort/rijndael-nodejs
cryptography nodejs typescript webpack
Last synced: 8 months ago
JSON representation
Implementation of the rijndael encryption algorithm.🛡️
- Host: GitHub
- URL: https://github.com/nexckycort/rijndael-nodejs
- Owner: nexckycort
- Created: 2021-07-08T12:04:24.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2021-11-02T14:16:07.000Z (over 4 years ago)
- Last Synced: 2025-09-21T13:58:29.744Z (9 months ago)
- Topics: cryptography, nodejs, typescript, webpack
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/@nexckycort/rijndael-nodejs
- Size: 580 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# rijndael-nodejs
Implementation of the rijndael encryption algorithm.
| Statements | Branches | Functions | Lines |
| ----------------------------------------------------------------------------- | ------------------------------------------------------------------------- | --------------------------------------------------------------------------- | ------------------------------------------------------------------- |
|  |  |  |  |
## Install
```npm
npm install @nexckycort/rijndael-nodejs
```
## Usage
```javascript
import rijndael from '@nexckycort/rijndael-nodejs'
const saltBytes = Buffer.from('salttest', 'ascii')
const key = 'keytest'
const algorithm = 'aes256'
const encryptRijndael = rijndael(saltBytes, key, algorithm)
const text = 'test'
const encryptText = encryptRijndael(text)
console.log(encryptText) // output: gv/aprKdK7hm/s91m1VW8w==
```
## Example in csharp
```csharp
using System;
using System.IO;
using System.Security.Cryptography;
using System.Text;
namespace rijndael_csharp {
class Program {
static void Main(string[] args) {
var encryptText = rijndael("test");
Console.WriteLine(encryptText); // output: gv/aprKdK7hm/s91m1VW8w==
}
public static string rijndael(String password) {
byte[] saltBytes = Encoding.ASCII.GetBytes("salttest");
Rfc2898DeriveBytes key = new Rfc2898DeriveBytes("keytest", saltBytes);
RijndaelManaged rijAlg = new RijndaelManaged();
rijAlg.Key = key.GetBytes(rijAlg.KeySize / 8);
rijAlg.IV = key.GetBytes(rijAlg.BlockSize / 8);
byte[] encrypted;
ICryptoTransform encryptor = rijAlg.CreateEncryptor(rijAlg.Key, rijAlg.IV);
using (MemoryStream msEncrypt = new MemoryStream()) {
using (CryptoStream csEncrypt = new CryptoStream(msEncrypt, encryptor, CryptoStreamMode.Write)) {
using (StreamWriter swEncrypt = new StreamWriter(csEncrypt)) {
swEncrypt.Write(password);
}
encrypted = msEncrypt.ToArray();
}
}
return Convert.ToBase64String(encrypted);
}
}
}
```
# Contributing
If someone wants to add or improve something, I invite you to collaborate directly in this repository: [@nexckycort/rijndael-nodejs](https://github.com/nexckycort/rijndael-nodejs)
# License
@nexckycort/rijndael-nodejs is released under the [MIT License](https://opensource.org/licenses/MIT).