小编Ran*_*rez的帖子

如何在php中加密/解密数据?

我现在是一名学生,我正在学习PHP,我正在尝试在PHP中对数据进行简单的加密/解密.我做了一些在线研究,其中一些很混乱(至少对我而言).

这是我正在尝试做的事情:

我有一个由这些字段组成的表(UserID,Fname,Lname,Email,Password)

我想要的是加密所有字段然后解密(是否可以sha256用于加密/解密,如果不是任何加密算法)

我想要学习的另一件事是如何创造一种hash(sha256)与良好"盐"相结合的方式.(基本上我只是希望有一个简单的加密/解密实现,hash(sha256)+salt) 先生/女士,你的答案会有很大的帮助,非常感谢.谢谢++

php security encryption cryptography encryption-symmetric

108
推荐指数
5
解决办法
17万
查看次数

在jquery中如何通过索引["key"]或值删除数组元素

jQuery/JavaScript中,如何删除数组元素?

就像是:

array.remove(array["key"]);

// or 

array.remove("value")
Run Code Online (Sandbox Code Playgroud)

javascript jquery

19
推荐指数
3
解决办法
8万
查看次数

如何对使用Entity Framework的存储库模式进行单元测试?

我目前正在尝试对通过Entity Framework进行的存储库进行单元测试:

我想要发生的是测试存储库而不实际发送/连接到实际的数据库,我想这样做而不使用任何模拟框架.

目前我的测试是将数据发送到数据库,我想要发生的是测试添加/删除等方法而不将实际数据发送到数据库,因为它仅用于测试.

这是存储库:

namespace AbstractFactory.Repository
{
    using System.Collections.Generic;
    using System.Data.Entity;
    using System.Linq;

    /// <summary>
    /// This class serves as the structure of the Author repository using a database
    /// </summary>
    public class DbAuthorRepository : IRepository<AuthorEntity>
    {

        private AbstractFactoryPatternEntities context;

        public DbAuthorRepository(AbstractFactoryPatternEntities context)
        {
            this.context = context;
        }

        /// <summary>
        /// Adds the specified author.
        /// </summary>
        /// <param name="author">The author.</param>
        public void Add(AuthorEntity author)
        {
            context.AuthorEntities.Add(author);
        }

        /// <summary>
        /// Removes the specified author.
        /// </summary>
        /// <param …
Run Code Online (Sandbox Code Playgroud)

c# unit-testing entity-framework repository-pattern

15
推荐指数
2
解决办法
2万
查看次数

如何在实体框架中过滤"包含"实体?

实体:

    public class Room
    {
        public Room()
        {
            this.Reservations = new HashSet<Reservation>();
        }

        public int Id { get; set; }

        public decimal Rate { get; set; }

        public int HotelId { get; set; }

        public virtual Hotel Hotel { get; set; }

        public virtual ICollection<Reservation> Reservations { get; set; }
    }

    public class Hotel
    {
        public Hotel()
        {
            this.Rooms = new HashSet<Room>();
        }

        public int Id { get; set; }

        public string Name { get; set; }

        public virtual ICollection<Room> …
Run Code Online (Sandbox Code Playgroud)

c# entity-framework entity-framework-6

13
推荐指数
3
解决办法
1万
查看次数

Linq to SQL,InsertOnSubmit vs. InsertAllOnSubmit性能?

两者之间的性能是否存在巨大差异,例如我有这两个代码片段:

public void Insert(IEnumerable<ManageGeofenceViewModel> geofences)
{
    var insertGeofences = new List<Geofence>();

    foreach(var geofence in geofences)
    {
        Geofence insertGeofence = new Geofence
        {
            name = geofence.Name,
            radius = geofence.Meters,
            latitude = geofence.Latitude,
            longitude = geofence.Longitude,
            custom_point_type_id = geofence.CategoryID
        };

        insertGeofences.Add(insertGeofence);

    }

    this.context.Geofences.InsertAllOnSubmit(insertGeofences);
    this.context.SubmitChanges();
}
Run Code Online (Sandbox Code Playgroud)

VS

public void Insert(IEnumerable<ManageGeofenceViewModel> geofences)
{
    foreach(var geofence in geofences)
    {
        Geofence insertGeofence = new Geofence
        {
            name = geofence.Name,
            radius = geofence.Meters,
            latitude = geofence.Latitude,
            longitude = geofence.Longitude,
            custom_point_type_id = geofence.CategoryID
        };
        this.context.Geofences.InsertOnSubmit(insertGeofence);
    }
    this.context.SubmitChanges();
} …
Run Code Online (Sandbox Code Playgroud)

c# sql linq linq-to-sql

9
推荐指数
1
解决办法
1万
查看次数

如何正确使用连接/子查询从多个表中选择数据?(PHP,MySQL的)

我有三张桌子,如下图所示.

注意: projectheader表的Lead列存储员工ID.

在此输入图像描述

我想要的是能够检索表格中的那个我的目标(Lead,显示该员工的主要名称)

我能够使用下面的查询来做到这一点.

SELECT DISTINCT
  projectdetails.ProjectDetailsID,
  projectheader.ProjectID,
  projectheader.ProjectName,
  projectheader.Lead,
  projectheader.StartDate,
  projectheader.EndDate,
  projectheader.Status,
  projectheader.Remarks,
  projectdetails.EmployeeID,
  employee.Firstname,
  employee.Lastname,
  Lead.Leadname
FROM
  projectheader,
  projectdetails,
  employee,
  ( SELECT
      projectheader.ProjectID AS projid,
      CONCAT(employee.Firstname,' ',employee.Lastname) AS Leadname
      FROM employee, projectheader, projectdetails 
      WHERE projectheader.ProjectID = projectdetails.ProjectID 
      AND projectheader.Lead = employee.EmployeeID
  ) AS Lead
WHERE projectheader.ProjectID = projectdetails.ProjectID
AND projectdetails.EmployeeID = employee.EmployeeID
AND projectheader.ProjectID = Lead.projid
AND projectdetails.ProjectID = Lead.projid
Run Code Online (Sandbox Code Playgroud)

得到了这个结果: 在此输入图像描述

我使用的查询很长,也许编写得不好,我想知道如何通过使用join或子​​查询使用更好的sql查询来实现相同结果的不同方式.(我在projectdetails.ProjectDetailsID的开头添加了一个DISTINCT,因为没有它会重复一些行).我正在寻找比我目前正在使用的查询更好的查询.

php mysql join subquery

8
推荐指数
1
解决办法
3万
查看次数

在C#中如何正确实现命令设计模式?

我正在研究设计模式,我目前正在研究命令模式.

这是我目前的代码:

// this is the receiver
class Calculator : IReceiver
{
    int x;
    int y;

    CommandOptions command;

    public Calculator(int x, int y)
    {
        this.x = x;
        this.y = y;
    }

    public void SetAction(CommandOptions command)
    {
        this.command = command;
    }

    public int GetResult()
    {
        int result = 0;

        switch(this.command)
        {
            case CommandOptions.ADD:
                result = this.x + this.y;
                break;

            case CommandOptions.SUBTRACT:
                result = this.x - this.y;
                break;

            case CommandOptions.MULTIPLY:
                result = this.x * this.y;
                break;
        }

        return result;
    }
}

// …
Run Code Online (Sandbox Code Playgroud)

c# design-patterns command-pattern

8
推荐指数
1
解决办法
1万
查看次数

如何在不使用查询语法的情况下在Entity Framework中执行左外连接?

我正在尝试使用linq的查询语法将此查询转换为基于方法的语法.

这是查询:

  var products = from p in context.Products
                 join t in context.TopSellings
                 on p.Id equals t.Id into g
                 from tps in g.DefaultIfEmpty()
                 orderby tps.Rating descending
                 select new
                 {
                     Name = p.Name,
                     Rating = tps.Rating == null ? 0 : tps.Rating
                 };
Run Code Online (Sandbox Code Playgroud)

上面的查询产生这个SQL查询:

{SELECT 
    [Project1].[Id] AS [Id], 
    [Project1].[Name] AS [Name], 
    [Project1].[C1] AS [C1]
    FROM ( SELECT 
        [Extent1].[Id] AS [Id], 
        [Extent1].[Name] AS [Name], 
        CASE WHEN ([Extent2].[Rating] IS NULL) THEN 0 ELSE [Extent2].[Rating] END AS [C1], 
        [Extent2].[Rating] AS [Rating]
        FROM  [dbo].[Products] AS …
Run Code Online (Sandbox Code Playgroud)

c# linq entity-framework

7
推荐指数
1
解决办法
1万
查看次数

如何在asp.net C#4.0中调用异步方法?

我知道.net 4.5有等待,异步关键字允许轻松调用异步方法.我目前正在研究如何在C#4.0中进行异步调用.我想要的一个例子是进行异步调用,其中datagrid是数据绑定.

如果你能给我一些链接,我会非常感激.

c# asp.net asynchronous c#-4.0

6
推荐指数
1
解决办法
1万
查看次数

使用 React,在 StrictMode 中不推荐使用 findDOMNode 在使用 react-transition-group 时作为警告抛出

我正在使用 react-transition-group 包,我尝试在 CSSTransition 组件上使用 nodeRef 道具,并在我的组件上添加了一个包装器,但我仍然收到有关 findDOMNode 的警告。

这是代码:

 <CSSTransition
        key={entry.id}
        timeout={500}
        classNames="timesheet-entry"
      >
          <TimesheetEntry
            taskOptions={taskOptions || []}
            deleteHandler={(event) => {
              deleteHandler(event, entry.id.toString());
            }}
            data={entry}
            dateChangeHandler={(date: Date) =>
              dateChangeHandler(date, entry.id)
            }
            hoursChangeHandler={(event) => hoursChangeHandler(event, entry.id)}
            taskCodeChangeHandler={(event, value) =>
              taskCodeChangeHandler(event, value, entry.id)
            }
          />
      </CSSTransition>
Run Code Online (Sandbox Code Playgroud)

TimesheetEntry 组件的代码:

function TimesheetEntry(props: TimesheetEntryProps) {
  return (
    <div>
      <MuiPickersUtilsProvider utils={DateFnsUtils}>
        <KeyboardDatePicker
          label="Date"
          style={{ marginRight: '15px', height: '20px', marginTop: '-2px' }}
          disableToolbar
          variant="inline"
          format="MM/dd/yyyy"
          margin="normal"
          value={props.data.date}
          onChange={props.dateChangeHandler}
          size="small"
          KeyboardButtonProps={{
            'aria-label': 'change date',
          }}
        />
      </MuiPickersUtilsProvider> …
Run Code Online (Sandbox Code Playgroud)

reactjs react-transition-group

6
推荐指数
1
解决办法
4589
查看次数