Comments (3)
import bigInt from 'big-integer';
import {
concatBytes,
bytesToBigInt,
} from '@mtproto/core/src/utils/common/index.js';
import crypto from 'crypto';
export async function getVParams(api, password) {
const getPasswordConf = await api.call('account.getPassword');
const { new_algo = {} } = getPasswordConf;
const {
g, p, salt1, salt2
} = new_algo;
const SH = (data, salt) => {
const hash = crypto.createHash('sha256');
hash.update(concatBytes(salt, data, salt));
return hash.digest();
};
const PH1 = (password, salt1, salt2) => {
const hash1 = SH(SH(password, salt1), salt2);
return hash1;
};
const PH2 = (password, salt1, salt2) => {
const ph1Result = PH1(password, salt1, salt2);
const pbkdf2Result = crypto.pbkdf2Sync(
ph1Result,
salt1,
100000,
32,
'sha256'
);
return SH(pbkdf2Result, salt2);
};
const encoder = new TextEncoder();
const gBigInt = bigInt(g);
const pBigInt = bytesToBigInt(p);
const x = PH2(encoder.encode(password), salt1, salt2);
const xBigInt = bytesToBigInt(x);
const vBigInt = gBigInt.modPow(xBigInt, pBigInt);
console.log('vBigInt:', vBigInt);
const new_password_hash = crypto
.createHash('sha256')
.update(vBigInt.toString())
.digest();
// 将 Buffer 转换为 Uint8Array
const new_password_hash_uint8 = new Uint8Array(new_password_hash.buffer);
console.log('new_password_hash:', new_password_hash);
return {
...getPasswordConf,
new_password_hash: new_password_hash_uint8,
};
}
from mtproto-core.
{
"code": 400,
"msg": "NEW_SALT_INVALID"
}
or
{
"code": 400,
"msg": "NEW_PASSWORD_BAD"
}
from mtproto-core.
please help me
from mtproto-core.
Related Issues (20)
- Support for "flags2:#" for Layer 140-144 in parser/builder HOT 1
- Browserify
- Is it safe to share peer_id and access_hash pair to public?
- How to inflate a stripped_thumb in JS
- this lib is a joke HOT 6
- When 140, 141, 142, 143, 144, 145 schema? HOT 5
- How to download photo from message.media HOT 1
- Example doesn't work
- First example doesnt work
- Facing Invalid Channel Problem
- messages.getAllChats always retrun INPUT_METHOD_INVALID_2271179966_* HOT 21
- sendReaction throws error "REACTION_INVALID"
- channels.getForumTopics always return "Cannot read properties of undefined (reading 'call')" HOT 1
- IP white list method - amazon changer & checker - local server tunnel
- auth.sendCode method never returns HOT 1
- users.getFullUser behaves differently from different login
- "Not found predicate with id: .." results in RangeError. HOT 1
- Can't work with invite links, always getting INVITE_HASH_EXPIRED HOT 1
- api.call() doesn't return HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mtproto-core.