简体   繁体   English

如何在 .netcore 运行时获取项目 GUID?

[英]How to get project GUID in runtime of .netcore?

I'm the newer of .netcore.我是.netcore 的更新者。

Now, I have a sql connection string using guid to encrypt, and I generate a guid in project.现在,我有一个使用 guid 加密的 sql 连接字符串,并在项目中生成一个 guid。

<PropertyGroup>
    ...
    <ProjectGuid>{D830E0EE-9D0B-4FC2-A609-4661990159D2}</ProjectGuid>
</PropertyGroup>

Then, I want to get it when runtime for decrypt, and I try to do below:然后,我想在运行时解密时得到它,我尝试在下面做:

object[] guids = assembly.GetCustomAttributes(typeof(GuidAttribute), false);
string guid = ((GuidAttribute)guids[0]).Value;

The GetCustomAttributes could not use in here, because it is not assembly . GetCustomAttributes不能在这里使用,因为它不是assembly

How can I do anything?我该怎么做?

Thx.谢谢。

This information is not compiled into your application and not available at runtime.此信息不会编译到您的应用程序中,并且在运行时不可用。

If you bundle a secret with your application, it will not be secret because no extra privileges are needed to load the secret into memory.如果您将机密与您的应用程序捆绑在一起,它就不是机密,因为将机密加载到 memory 不需要额外的权限。

If you use SqlServer use Integrated Security.如果您使用 SqlServer,请使用集成安全性。 In that case, you don't deal with passwords at all and the user account is used.在这种情况下,您根本不需要处理密码,而是使用用户帐户。 Such mechanism is available to many database systems, even if you don't use SqlServer.这种机制适用于许多数据库系统,即使您不使用 SqlServer。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM