🚀 Launch Week Day 5:Introducing Immutable Scans.Learn More
Socket
Book a DemoInstallSign in
Socket

Zzz.Tool

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

Zzz.Tool

Package Description

nugetNuGet
Version
1.1.0
Version published
Maintainers
1
Created
Source

������־

1.0.0 ��Ŀ�������滮ģ��

1.0.1 ������������Utils������չ

  • ��������ַ�������
  • �����ַ�����չ
  • ��������ʱ���ʽʱ���ת����չ
  • ����ö����չ
  • ����ʵ��ӳ����չ
  • ����ͳһ�����ࡢ��ҳ����չ��ͳһ�쳣��

Use

//ֻ�������ֵ��ַ���
RandomStringUtils.RandomNumeric(10);
//ֻ������ĸ���ַ���
RandomStringUtils.RandomAlphabetic(10);
//�������֡���ĸ���ַ���
RandomStringUtils.RandomAlphanumeric(10);

//GUID
StringUtils.NewId();
//�����ţ�yyyyMMddHHmmssfff+7λ�������
StringUtils.NewOrderNo();
//����(Ĭ��*)
"zz123456".Mask('#');
//Base64
"zz123456".ToBase64String();
"zz123456".ToBase64String().Base64ToString();

//ʱ���ַ���(Ĭ��'/'�ָ�) yyyy/mm/dd HH:mm:ss:fff
DateTime.Now.ToCommonDateTime('-');
DateTime.Now.ToCommonDateTimeWithSecond();
//ʱ��תʱ������룩
DateTime.Now.ToTotalSeconds();
//ʱ��תʱ��������룩
DateTime.Now.ToTotalMilliSeconds();
//ʱ���תʱ��
DateTime.Now.ToTotalSeconds().ToDateTimeWithSecond();
DateTime.Now.ToTotalSeconds().ToDateTimeWithMilliSecond();
//ʱ���
date1.DateDiff(date2);

//��ȡö��������DescriptionAttribute��
user.UserTypeEnum.GetDescription()

//ӳ��
Users user = new Users();
user.Map<Users,UsersDto>();
userList.Map<List<Users>,List<UsersDto>>()

//ͳһ����ֵ{"code":0,"msg":"success"}
R.Ok();
//ͳһ����ֵ{"code":0,"msg":"success","data":obj}
R.Ok().Put(obj);
//ͳһ����ֵ{"code":500,"msg":"δ֪�쳣������ϵ����Ա"}
R.Error();
//ͳһ����ֵ{"code":code,"msg":error}
R.Error(code,"error");

//��ҳ
var list = Users.GetUserList();
//������ҳ
new PageUtils<Users>(list.Skip(1).Take(3), list.Count(), p.PageSize, p.Page);
//��ҳ��ѯ����Model�̳�IPage
new PageUtils<Users>(IPage,xxx.AsQueryable())
//������ҳ
xxx.AsQueryable().ToPage(IPage);
//ҳ���ҳ
xxx.AsQueryable().ToPage(pageIndex,pageSize);

//�쳣
throw new ZzzException("�׳��쳣");
throw new ZzzException(5001,"�׳��쳣");

1.0.2 ����У�顢Jwt��Json

  • �����ַ���У����չ���Զ���У��
  • ����Jwt��װ
  • Json��չ
  • ͼƬ��������չ

Use

//��ֵУ��
//������https://any86.github.io/any-rule/
TryValidate("��У���ַ���","����");
TryValidate(�ַ����б�,����);
"www.xxxxx.com".IsURL();
"https://1234.345345/sdd/aa.png".IsImagePath();
"1233333333333333".IsBackCardId();
"XX88888".IsPlate();
"18754564845".IsMobilePhone();
"1234564778975646".IsIDCard();
5.Range(1,4);

//����JWT
var securityKey = "oInZ1834jQv04qweKgeEaaGh";
JwtUtils.GenerateToken("123456", securityKey,7);
//��ȡJWTƾ֤�û���Ϣ
JwtUtils.GetPrincipal(token, securityKey);
//��ȡJWT����
JwtUtils.GetPayload(token);
//��֤
JwtUtils.CheckToken(token, securityKey);
JwtUtils.IsExp(token);

//Json��ʵ��ת��
user.ToJson(true);
json.ToObject<Users>();

//Image��
"xxx.png".IsImage();
ImageUtils.IsImage("xxx.png");
//ͼƬ����
ImageUtils.Resize(@"StaticFile\ccc.jpg", "1111.jpg", 100, 100);
@"StaticFile\ccc.jpg".Resize(100,100);
@"StaticFile\ccc.jpg".Resize("2222.png",100,100);

//ͼƬ��ʽת����֧��Png|Jpeg|WbeP|Gif|Bmp|Pbm(Ĭ������GUID)
@"StaticFile\ccc.jpg".ToWebP();
ImageUtils.ToWenP("xxxx");
//ͼƬ��ʽת��ָ�����ƣ�Ŀǰֻ֧�ֱ���ͼƬ��
@"StaticFile\ccc.jpg".ToPng("�޸�����.png");
ImageUtils.ToWenP("xxxx.png""newName.WebP");
//֧���ļ���
using var stream = new FileStream(@"StaticFile\ccc.jpg", FileMode.Open);
stream.SaveWebP(@"StaticFile\");

1.1.0 ����

  • MD5����|���Ρ���չ
  • DES����|���ܡ���չ
  • RSA����|���ܡ�ǩ��|��ǩ����չ

Use


//AES���ܽ���|��չ
EncryptUntils.AesEncrypt("key", "iv","content");
EncryptUntils.AESDecrypt("key", "iv", "content");
"zz123456".AESEncrypt("key","iv");
"asdasdasd".AESDecrypt("key"��"iv");

//AESGCM���ܽ���|��չ
EncryptUntils.AesGcmEncrypt("key", "iv", "zz123456", out string tag, out string cipher);
EncryptUntils.AesGcmDecrypt("key", "iv", tag, cipher);
"zz123456".AESGcmEncrypt("key","iv",out tag);
"asdasdasd".AESGcmDecrypt("key","iv",tag);

//AESCCM���ܽ���|��չ
EncryptUntils.AesCcmEncrypt("key", "iv", "zz123456", out string tag, out string cipher);
EncryptUntils.AesCcmDecrypt("key", "iv", tag, cipher);
"zz123456".AesCcmEncrypt("key","iv",out tag);
"asdasdasd".AesCcmDecrypt("key","iv",tag);

//RSA���ܽ���|��չ
EncryptUntils.RSAEncrypt("zz123456", publicKey);
EncryptUntils.RSADecrypt(cipher, privateKey)
"zz123456".RSAEncrypt(publicKey);
cipher.RSADecrypt(privateKey)
//ǩ����ǩ
EncryptUntils.RSASignWithSAH256("zz123456", privateKey);
EncryptUntils.RSAVerifyWithSAH256("zz123456", sign, privateKey);
"zz123456".RSASignWithSAH1(privateKey);
"zz123456".RSAVerifyWithSAH1(enStr,publicKey);

//MD5���ܽ���|��չ
"zz123456".MD5Encrypt();
"zz123456".MD5Encrypt("salt");

1.2.0 �����

  • �ļ���д
  • �ļ�ѹ��
  • XML��д��ת��

Keywords

FAQs

Package last updated on 26 Aug 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts