Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Generating a seed: a general approach
// The snippet is a part of the IOTA Developer Essentials project. You can reach it at
// Complete description and story behind the snippet is available at:
//based on
using System.Security.Cryptography;
private static string NewRandomSeed()
string iotaseed = string.Empty;
using (RNGCryptoServiceProvider _ran = new RNGCryptoServiceProvider()) // The class provides crypto-safe random generator
string[] _seed = new string[] { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "9" };
byte[] _data = new byte[8]; //8 bytes to hold an unsigned bits int
for (int i = 0; i <= 80; i++) //The number times this will run in orde to fill the 81 char requirment
var gennum = BitConverter.ToUInt64(_data, 0);
var _num = (gennum % 27);
iotaseed += _seed[_num];
return iotaseed;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment