Login function
Posted: Tue Feb 18, 2025 2:16 pm
Hello, dear community
I have a question regarding my project, which was running on WinCC OA 3.12. I have a login panel that requires a username and password to open other panels. After upgrading the project to WinCC OA 3.20, I am now facing an issue where the `loginCheck()` function is no longer working. Additionally, I noticed that many files in the `libs` directory have changed.
Is there any way to fix the function or find a suitable replacement?
here is the click code of click button in my panel :
main()
{
//Autologin
EncrypDetailsCnx();
logincheck(bAllowRemoteLogin);
}
and this is the scopelib code of my panel :
#uses "CtrlCrypt.dll"
bool bDoPara;
bool useNewPt;
int iCloseModules = 1;
bool bAllowRemoteLogin=false;
string FICDETAILSAUTOLOGIN = DATA_PATH + "loginDetail";
string KEYENCRYPT = cryptoHash("ALG1sc@dA!");
void thdAutoLogin()
{
file fd;
int Err;
delay(20);
fd = fopen(FICDETAILSAUTOLOGIN, "rb");
Err = ferror(fd);
if (Err != 0) {
Log0(__FUNCTION__,__LINE__,"[ Startpanel ] Fichier '"+FICDETAILSAUTOLOGIN+"' introuvable!");
}
else {
string CryptEnrStr, DecryptEnr, Nom, Pwd, ChpPwd;
dyn_string DetailsEnr;
bool AccChpNom,AccChpPwd;
blob CryptEnr;
int LgEnr;
LgEnr = getFileSize(FICDETAILSAUTOLOGIN)+1;
blobRead(CryptEnr,LgEnr,fd);
//blobGetValue(CryptEnr, 0 ,CryptEnrStr, bloblen(CryptEnr));
desDecrypt(CryptEnr, KEYENCRYPT, DecryptEnr);
Nom = substr(DecryptEnr,0,strpos(DecryptEnr+":::",":::"));
Pwd = substr(DecryptEnr,strpos(DecryptEnr+":::",":::")+3);
getMultiValue("name" ,"enabled", AccChpNom,
"password","enabled", AccChpPwd,
"password","text" , ChpPwd);
if (AccChpNom && AccChpPwd && (ChpPwd == "")) {
setMultiValue("name" ,"text", Nom,
"password","text", Pwd);
logincheck(bAllowRemoteLogin);
}
fclose(fd);
}
}
void EncrypDetailsCnx()
{
file fd;
int Err;
string Nom, Pwd;
blob CryptEnr;
fd = fopen(FICDETAILSAUTOLOGIN, "wb");
Err = ferror(fd);
if (Err != 0) {
Log0(__FUNCTION__,__LINE__,"[ Startpanel ] Erreur sur l'écriture du fichier '"+FICDETAILSAUTOLOGIN+"'");
}
else {
string Nom;
getMultiValue("name" ,"text",Nom,
"password","text",Pwd);
desEncrypt(Nom + ":::" + Pwd, KEYENCRYPT, CryptEnr);
if (Nom != "") {
blobWrite( CryptEnr, fd );
}
fflush(fd);
fclose(fd);
}
}
string tohex(string text)
{
string Str, b;
char c;
for(int i=0; i<strlen(text); i++)
{
c = text;
sprintf(b, "%02X",c);
Str = Str + b;
}
return Str;
}
Thanks in advance!
I have a question regarding my project, which was running on WinCC OA 3.12. I have a login panel that requires a username and password to open other panels. After upgrading the project to WinCC OA 3.20, I am now facing an issue where the `loginCheck()` function is no longer working. Additionally, I noticed that many files in the `libs` directory have changed.
Is there any way to fix the function or find a suitable replacement?
here is the click code of click button in my panel :
main()
{
//Autologin
EncrypDetailsCnx();
logincheck(bAllowRemoteLogin);
}
and this is the scopelib code of my panel :
#uses "CtrlCrypt.dll"
bool bDoPara;
bool useNewPt;
int iCloseModules = 1;
bool bAllowRemoteLogin=false;
string FICDETAILSAUTOLOGIN = DATA_PATH + "loginDetail";
string KEYENCRYPT = cryptoHash("ALG1sc@dA!");
void thdAutoLogin()
{
file fd;
int Err;
delay(20);
fd = fopen(FICDETAILSAUTOLOGIN, "rb");
Err = ferror(fd);
if (Err != 0) {
Log0(__FUNCTION__,__LINE__,"[ Startpanel ] Fichier '"+FICDETAILSAUTOLOGIN+"' introuvable!");
}
else {
string CryptEnrStr, DecryptEnr, Nom, Pwd, ChpPwd;
dyn_string DetailsEnr;
bool AccChpNom,AccChpPwd;
blob CryptEnr;
int LgEnr;
LgEnr = getFileSize(FICDETAILSAUTOLOGIN)+1;
blobRead(CryptEnr,LgEnr,fd);
//blobGetValue(CryptEnr, 0 ,CryptEnrStr, bloblen(CryptEnr));
desDecrypt(CryptEnr, KEYENCRYPT, DecryptEnr);
Nom = substr(DecryptEnr,0,strpos(DecryptEnr+":::",":::"));
Pwd = substr(DecryptEnr,strpos(DecryptEnr+":::",":::")+3);
getMultiValue("name" ,"enabled", AccChpNom,
"password","enabled", AccChpPwd,
"password","text" , ChpPwd);
if (AccChpNom && AccChpPwd && (ChpPwd == "")) {
setMultiValue("name" ,"text", Nom,
"password","text", Pwd);
logincheck(bAllowRemoteLogin);
}
fclose(fd);
}
}
void EncrypDetailsCnx()
{
file fd;
int Err;
string Nom, Pwd;
blob CryptEnr;
fd = fopen(FICDETAILSAUTOLOGIN, "wb");
Err = ferror(fd);
if (Err != 0) {
Log0(__FUNCTION__,__LINE__,"[ Startpanel ] Erreur sur l'écriture du fichier '"+FICDETAILSAUTOLOGIN+"'");
}
else {
string Nom;
getMultiValue("name" ,"text",Nom,
"password","text",Pwd);
desEncrypt(Nom + ":::" + Pwd, KEYENCRYPT, CryptEnr);
if (Nom != "") {
blobWrite( CryptEnr, fd );
}
fflush(fd);
fclose(fd);
}
}
string tohex(string text)
{
string Str, b;
char c;
for(int i=0; i<strlen(text); i++)
{
c = text;
sprintf(b, "%02X",c);
Str = Str + b;
}
return Str;
}
Thanks in advance!