トップ 差分 一覧 ソース 検索 ヘルプ RSS ログイン

LN-useradd

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# import pandas
# md = pandas.read_csv('N.csv')
## print ( md )

import getpass
import crypt
import hashlib
import random

import csv
with open('N.csv', 'r') as file:
   reader = csv.reader(file)
   for row in reader:
       #print ( row[0] ) ## Number
       print ( "# " + row[1] ) ## Name
       ##  print ( " " )
       pw = row[3]
       salt = hashlib.sha512(row[5].encode('utf-8')).hexdigest()
       ## salt = hashlib.sha256(bytes(random.randint(32,90))).hexdigest() 
       # print ( pw )
       # crpy = crypt.crypt( pw , "$6$" + salt + "$" ) 
       # crpy = crypt.crypt( pw , "$1$" + salt + "$" ) 
       # print ( salt[0]+salt[7] )
       crpy = crypt.crypt( pw , salt[0]+salt[7] ) 
       print ( "adduser -p " + crpy + " "+row[5] )

# print ( crypt.methods )

# pw = getpass.getpass()
# ## salt = hashlib.sha1(str(random.random())).hexdigest()
# # salt = hashlib.sha256(b'test').hexdigest()
# salt = hashlib.sha1(bytes(random.randint(32,90))).hexdigest()
# print ( crypt.crypt( pw , "$1$" + salt + "$") )