swad-core/swad_cryptography.h

54 lines
2.4 KiB
C
Raw Normal View History

2014-12-01 23:55:08 +01:00
// swad_cryptography.h: cryptography
#ifndef _SWAD_COM
#define _SWAD_COM
/*
SWAD (Shared Workspace At a Distance in Spanish),
is a web platform developed at the University of Granada (Spain),
and used to support university teaching.
This file is part of SWAD core.
Copyright (C) 1999-2024 Antonio Ca<EFBFBD>as Vargas
2014-12-01 23:55:08 +01:00
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*****************************************************************************/
/***************************** Public constants ******************************/
/*****************************************************************************/
2017-03-11 22:17:44 +01:00
#define Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64 43 // 42,66 base-64 characters store 256 bits
#define Cry_LENGTH_ENCRYPTED_STR_SHA512_BASE64 86 // 85,33 base-64 characters store 512 bits
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
/********************************* Headers ***********************************/
/*****************************************************************************/
#include <stdio.h> // For FILE
2014-12-01 23:55:08 +01:00
#include "sha2/sha2.h" // For sha-256 and sha-512 algorithms
/*****************************************************************************/
/***************************** Public prototypes *****************************/
/*****************************************************************************/
2017-01-28 15:58:46 +01:00
void Cry_EncryptSHA256Base64 (const char *PlainText,
2017-03-07 01:56:41 +01:00
char EncryptedText[Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64 + 1]);
2017-01-28 15:58:46 +01:00
void Cry_EncryptSHA512Base64 (const char *PlainText,
char EncryptedText[Cry_LENGTH_ENCRYPTED_STR_SHA512_BASE64 + 1]);
2014-12-01 23:55:08 +01:00
void Cry_CreateUniqueNameEncrypted (char *UniqueNameEncrypted);
char *Cry_GetUniqueNameEncrypted (void);
2016-04-04 14:48:12 +02:00
2014-12-01 23:55:08 +01:00
#endif