-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcryptoTest.js
More file actions
77 lines (59 loc) · 1.86 KB
/
cryptoTest.js
File metadata and controls
77 lines (59 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// const crypto = require('crypto')
// const hash = crypto.createHash('sha256')
// hash.update('a')
// const digest = hash.digest('hex')
// console.log('sha256', digest)
// const bcrypt = require('bcrypt')
// const userPassword = 'hello123'
// const hashedPassword = bcrypt.hashSync(userPassword, 12)
// console.log(hashedPassword)
// console.log(bcrypt.compareSync('nope', hashedPassword))
// const cryptoJs = require('crypto-js')
// const stringToEncrypt = 'hello i am a secret message'
// const encryptionKey = 'myKey'
// const myEncryption = cryptoJs.AES.encrypt(stringToEncrypt, encryptionKey)
// console.log(myEncryption)
// const decryptedMessage = cryptoJs.AES.decrypt(myEncryption.toString(), encryptionKey)
// console.log(decryptedMessage.toString(cryptoJs.enc.Utf8))
const axios = require("axios")
const db = require('./models')
// db.user_fish.create({
// userId: 2,
// fishId: 1,
// title: "huge tuna",
// length: 10,
// weight: 10,
// description: "it was an awesome",
// img: 'https://www.thefisherman.com/wp-content/uploads/2021/05/NOAA-NEWS.jpg',
// location: "Mauritius"
// }).then(_catch => {
// console.log(_catch);
// }).catch(err => {
// console.log(err);
// });
// this is my test JS where i use to do random task such as update my users tables
// db.user.update(
// { email: "Test3@gmail" },
// { where: { id: 3 } }
// )
// .then(numRowsAffected => {
// if (numRowsAffected > 0) {
// console.log("User's name updated successfully");
// } else {
// console.log("No rows were updated");
// }
// })
// .catch(error => console.log(error));
db.fish.findAll({
where: { img: null }
}).then(fishList => {
for (const fish of fishList) {
db.fish.update({
img: "https://i.imgur.com/An0tyUy.jpg"
}, {
where: { id: fish.id }
}).catch(err => {
console.log(err);
});
}
});